package com.bjgov.scoresys.entity;
// default package

import static javax.persistence.GenerationType.IDENTITY;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.apache.commons.lang.StringUtils;
import org.hibernate.annotations.OrderBy;

import com.bjgov.scoresys.service.UserHandler;

/**
 * Project entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "project", catalog = "scoresys")
public class Project implements java.io.Serializable {

	// Fields

	private Integer id;
	private Integer userId;
	private String name;
	private Date createDate;
	private Date startTime;
	private Date endTime;
	private String constructUnit;
	private String designUnit;
	private String buildUnit;
	private String supervisorUnit;
	private String scoreUser;
	private Float constructUnitScore;
	private Float designUnitScore;
	private Float buildUnitScore;
	private Float supervisorUnitScore;
	private Short status;
	private Set<UserProject> userProjects = new HashSet<UserProject>(0);
	private Set<ProjectItems> projectItemses = new HashSet<ProjectItems>(0);

	// Constructors

	/** default constructor */
	public Project() {
	}

	/** minimal constructor */
	public Project(Integer userId, String name, Date createDate) {
		this.userId = userId;
		this.name = name;
		this.createDate = createDate;
	}

	/** full constructor */
	public Project(Integer userId, String name, Date createDate,
			Date startTime, Date endTime, String constructUnit,
			String designUnit, String buildUnit, String supervisorUnit,
			String scoreUser, Float constructUnitScore, Float designUnitScore,
			Float buildUnitScore, Float supervisorUnitScore, Short status,
			Set<UserProject> userProjects, Set<ProjectItems> projectItemses) {
		this.userId = userId;
		this.name = name;
		this.createDate = createDate;
		this.startTime = startTime;
		this.endTime = endTime;
		this.constructUnit = constructUnit;
		this.designUnit = designUnit;
		this.buildUnit = buildUnit;
		this.supervisorUnit = supervisorUnit;
		this.scoreUser = scoreUser;
		this.constructUnitScore = constructUnitScore;
		this.designUnitScore = designUnitScore;
		this.buildUnitScore = buildUnitScore;
		this.supervisorUnitScore = supervisorUnitScore;
		this.status = status;
		this.userProjects = userProjects;
		this.projectItemses = projectItemses;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "ID", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@Column(name = "[USER_ID]", nullable = false)
	public Integer getUserId() {
		return this.userId;
	}

	public void setUserId(Integer userId) {
		this.userId = userId;
	}

	@Column(name = "[NAME]", nullable = false, length = 200)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "[CREATE_DATE]", nullable = false, length = 19)
	public Date getCreateDate() {
		return this.createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	@Column(name = "[START_TIME]", length = 19)
	public Date getStartTime() {
		return this.startTime;
	}

	public void setStartTime(Date startTime) {
		this.startTime = startTime;
	}

	@Column(name = "[END_TIME]", length = 19)
	public Date getEndTime() {
		return this.endTime;
	}

	public void setEndTime(Date endTime) {
		this.endTime = endTime;
	}

	@Column(name = "[CONSTRUCT_UNIT]", length = 200)
	public String getConstructUnit() {
		return this.constructUnit;
	}

	public void setConstructUnit(String constructUnit) {
		this.constructUnit = constructUnit;
	}

	@Column(name = "[DESIGN_UNIT]", length = 200)
	public String getDesignUnit() {
		return this.designUnit;
	}

	public void setDesignUnit(String designUnit) {
		this.designUnit = designUnit;
	}

	@Column(name = "[BUILD_UNIT]", length = 200)
	public String getBuildUnit() {
		return this.buildUnit;
	}

	public void setBuildUnit(String buildUnit) {
		this.buildUnit = buildUnit;
	}

	@Column(name = "[SUPERVISOR_UNIT]", length = 200)
	public String getSupervisorUnit() {
		return this.supervisorUnit;
	}

	public void setSupervisorUnit(String supervisorUnit) {
		this.supervisorUnit = supervisorUnit;
	}

	@Column(name = "[SCORE_USER]", length = 2000)
	public String getScoreUser() {
		return this.scoreUser;
	}

	public void setScoreUser(String scoreUser) {
		this.scoreUser = scoreUser;
	}

	@Column(name = "[CONSTRUCT_UNIT_SCORE]", precision = 12, scale = 0)
	public Float getConstructUnitScore() {
		return this.constructUnitScore;
	}

	public void setConstructUnitScore(Float constructUnitScore) {
		this.constructUnitScore = constructUnitScore;
	}

	@Column(name = "[DESIGN_UNIT_SCORE]", precision = 12, scale = 0)
	public Float getDesignUnitScore() {
		return this.designUnitScore;
	}

	public void setDesignUnitScore(Float designUnitScore) {
		this.designUnitScore = designUnitScore;
	}

	@Column(name = "[BUILD_UNIT_SCORE]", precision = 12, scale = 0)
	public Float getBuildUnitScore() {
		return this.buildUnitScore;
	}

	public void setBuildUnitScore(Float buildUnitScore) {
		this.buildUnitScore = buildUnitScore;
	}

	@Column(name = "[SUPERVISOR_UNIT_SCORE]", precision = 12, scale = 0)
	public Float getSupervisorUnitScore() {
		return this.supervisorUnitScore;
	}

	public void setSupervisorUnitScore(Float supervisorUnitScore) {
		this.supervisorUnitScore = supervisorUnitScore;
	}

	@Column(name = "[STATUS]")
	public Short getStatus() {
		return this.status;
	}

	public void setStatus(Short status) {
		this.status = status;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "project")
	public Set<UserProject> getUserProjects() {
		return this.userProjects;
	}

	public void setUserProjects(Set<UserProject> userProjects) {
		this.userProjects = userProjects;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "project")
	@OrderBy(clause="id desc")
	public Set<ProjectItems> getProjectItemses() {
		return this.projectItemses;
	}

	public void setProjectItemses(Set<ProjectItems> projectItemses) {
		this.projectItemses = projectItemses;
	}

}